﻿using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;

using Core.Localization;
using Core.Model;
using Core.Model.Column;

namespace Model.HAZOP
{
    [Export(typeof(IExaminationModel))]
    public class HazopModel : IExaminationModel
    {	
		#region Constructor

		[ImportingConstructor]
		public HazopModel(LocalizationManager localizationManager)
		{
			_localizationManager = localizationManager;
		}

		#endregion

        #region Private fields

		private readonly LocalizationManager _localizationManager;

		private const string _name = "Model.HAZOP:Strings:HAZOP";

		private readonly IEnumerable<ExaminationColumn> _columns = new[]
		                                                          { 
																	   new ExaminationColumn("Model.HAZOP:Strings:Element", ColumnType.Regular),
																	   new ExaminationColumn("Model.HAZOP:Strings:Feature", ColumnType.Regular),
																	   new ExaminationColumn("Model.HAZOP:Strings:Keyword", ColumnType.Keyword),
																	   new ExaminationColumn("Model.HAZOP:Strings:Deviation", ColumnType.Regular),
																	   new ExaminationColumn("Model.HAZOP:Strings:Possible_reasons", ColumnType.Regular),
																	   new ExaminationColumn("Model.HAZOP:Strings:Consequences", ColumnType.Regular),
																	   new ExaminationColumn("Model.HAZOP:Strings:Existing_safety_precautions", ColumnType.Regular),
																	   new ExaminationColumn("Model.HAZOP:Strings:Demanded_activities", ColumnType.Regular),
																	   new ExaminationColumn("Model.HAZOP:Strings:Responsible_person", ColumnType.Regular)
                                                                   };

		#endregion

		#region IExaminationModel implementation

		public string Name { get { return _localizationManager.Localize(_name); } }

		public IEnumerable<ExaminationColumn> Columns { get { return _columns.Select(column => new ExaminationColumn(_localizationManager.Localize(column.Name), column.Type)); } }

		#endregion
    }
}